import { defHttp } from "@/utils/http";
import { baseUrlApi } from "./utils";

export type UpdateResult = {
  code: number;
  data: boolean;
  msg: string;
};

export type PageListResult = {
  code: number;
  data: {
    current: number;
    size: number;
    total: number;
    pages: number;
    records: [];
  };
  msg: string;
};

export type ListResult = {
  code: number;
  data: [];
  msg: string;
};

export type DetailResult = {
  code: number;
  data: any;
  msg: string;
};

/** 修改供应商 */
export const setSupplierUpdate = (data?: object) => {
  return defHttp.post<UpdateResult>({
    url: baseUrlApi("/supplier/update"),
    data
  });
};
/** 供应商列表带分页 */
export const getSupplierPagelist = (data?: object) => {
  return defHttp.post<PageListResult>({
    url: baseUrlApi("/supplier/pagelist"),
    data
  });
};
/** 供应商列表不带分页 */
export const getSupplierList = (data?: object) => {
  return defHttp.post<ListResult>({
    url: baseUrlApi("/supplier/list"),
    data
  });
};
/** 供应商详情 */
export const getSupplierDetail = (data?: object) => {
  return defHttp.post<DetailResult>({
    url: baseUrlApi("/supplier/detail"),
    data
  });
};
/** 删除供应商 */
export const setSupplierDelete = (data?: object) => {
  return defHttp.post<UpdateResult>({
    url: baseUrlApi("/supplier/delete"),
    data
  });
};

/** 新增供应商 */
export const setSupplierAdd = (data?: object) => {
  return defHttp.post<UpdateResult>({
    url: baseUrlApi("/supplier/add"),
    data
  });
};
